rm(list=ls())
library(foreign)
#setwd("/scratch/cds2083/")
setwd("~/Dropbox/colombiaaux/int-rev-out")

# Convert output datasets from csv to dta first 
# (spanish accents make csv fail to load)


intNames <- c(	"int_emp",
				"int_secure",
				"int_confident",
				"int_upbeat",
				"int_excompeers",
				"int_commander")

for(i in 1:10){
	dataIn <- read.dta(paste("COLOMBIA_STEP9_PSCORE_IMP",
								i,
								".dta",
								sep=""))  
	if(i == 1){
		pMat <- dataIn[,grep("p_int_", names(dataIn))]		
		iMat <- dataIn[,intNames]
	}
	if(i>1){
		pMat <- rbind(pMat,
				dataIn[,grep("p_int_", names(dataIn))])		
		iMat <- rbind(iMat,
				dataIn[,intNames])
	}

}

titleVec <- c(	"Ensure employment",
				"Provide security",
				"Instill confidence in govt.",
				"Ensure emotional wellbeing",
				"Reduce excom. peer relations",
				"Cut relations to commander")

pdf(file="pscore-hist.pdf",
		width=8,
		height=5)
par(mar=c(4,2,4,1))
par(mfrow=c(2,3))
par(pty="s")
for(j in 1:6){
hist(	pMat[iMat[,1]==1,j], 
		breaks=seq(0,1.025,.025),
		xlab="Propensity score",
		main=titleVec[j],
		xlim=c(0,1),
		ylim=c(0,2650))
box()
}
dev.off()
